package com.example.download;

import android.util.Log;
import com.example.util.FileUtil;

import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Jasic
 * Date: 12-11-27
 */
public class Mp3DownLoader extends HttpDownloader {

    public boolean storage(String fileName, String url) throws IOException {

        System.out.println("文件名:[" + fileName + "], 网络地址:[" + url + "]");

        File file = new File(fileName);

        if (!FileUtil.createFile(fileName)) {

            System.out.println("不存在此文件" + file.getAbsolutePath());
            return false;
        }
        byte[] temp = super.downLoad(url);
        long length = FileUtil.appedContent(file, temp);

        if (-1 == length) {
            return false;
        }
        System.out.println("保存文件成功，增加的长度为:" + length);
        return true;
    }
}
